<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <button>点击我获取xml</button>
</body>
<script>
        document.querySelector("button").onclick = function(){
            let xhr = new XMLHttpRequest();
            xhr.open("get","/xml",true);
            // 重写content-type；
            xhr.overrideMimeType("text/xml");
            xhr.onload = function(){
                // console.log(xhr.responseText);
                // console.log(xhr.responseXML);
                // console.log(xhr.response)
                let name =  xhr.responseXML.getElementsByTagName("name")[1].innerHTML;
                console.log(name);
            }
            xhr.send();
        }
    </script>
</html>